package com.reservation.controller.admin.manage;

import com.reservation.dto.admin.manage.ReceiveId;
import com.reservation.result.Result;
import com.reservation.service.AdminHomeService;
import com.reservation.service.AdminManageService;
import com.reservation.vo.admin.home.GetSystemInfo;
import com.reservation.vo.admin.rmanageuser.UserList;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "管理员用户管理相关接口")
@RestController
@RequestMapping("/api/admin")
@Slf4j
public class ManegeController {

    @Autowired
    private AdminManageService adminManageService;

    @PostMapping("/getUserList")
    public Result getUserList() {

        List<UserList> list = adminManageService.getUserList();
        return Result.success(list);
    }

    @PostMapping("/passUserAccount")
    public Result passUserAccount(@RequestBody ReceiveId receiveId) {

        return adminManageService.updateStates1(receiveId) ? Result.success("账户激活成功！") : Result.error("账户激活失败！");
    }

    @PostMapping("/rejectUserAccount")
    public Result rejectUserAccount(@RequestBody ReceiveId receiveId) {

        return adminManageService.updateStates3(receiveId) ? Result.success("审核成功！") : Result.error("审核失败！");
    }

    @PostMapping("/freezeUserAccount")
    public Result freezeUserAccount(@RequestBody ReceiveId receiveId) {

        return adminManageService.updateStates2(receiveId) ? Result.success("账户冻结成功！") : Result.error("账户冻结失败！");
    }

    @PostMapping("/unfreezeUserAccount")
    public Result unfreezeUserAccount(@RequestBody ReceiveId receiveId) {

        return adminManageService.updateStates1(receiveId) ? Result.success("账户解冻成功！") : Result.error("账户解冻失败！");
    }


}
/**账户状态: 0-待审核(客户注册后), 1-激活, 2-冻结, 3-已删除(逻辑删除)
 *
 */